

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>brevitas.proxy package &mdash; Brevitas 0.2.0-alpha documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/language_data.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> Brevitas
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"><ul>
<li><a class="reference internal" href="#">brevitas.proxy package</a><ul>
<li><a class="reference internal" href="#submodules">Submodules</a></li>
<li><a class="reference internal" href="#module-brevitas.proxy.parameter_quant">brevitas.proxy.parameter_quant module</a></li>
<li><a class="reference internal" href="#module-brevitas.proxy.quant_proxy">brevitas.proxy.quant_proxy module</a></li>
<li><a class="reference internal" href="#module-brevitas.proxy.runtime_quant">brevitas.proxy.runtime_quant module</a></li>
<li><a class="reference internal" href="#module-brevitas.proxy">Module contents</a></li>
</ul>
</li>
</ul>
</div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Brevitas</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>brevitas.proxy package</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/brevitas.proxy.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="brevitas-proxy-package">
<h1>brevitas.proxy package<a class="headerlink" href="#brevitas-proxy-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="module-brevitas.proxy.parameter_quant">
<span id="brevitas-proxy-parameter-quant-module"></span><h2>brevitas.proxy.parameter_quant module<a class="headerlink" href="#module-brevitas.proxy.parameter_quant" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="brevitas.proxy.parameter_quant.WeightQuantProxy">
<em class="property">class </em><code class="sig-prename descclassname">brevitas.proxy.parameter_quant.</code><code class="sig-name descname">WeightQuantProxy</code><span class="sig-paren">(</span><em class="sig-param">bit_width</em>, <em class="sig-param">quant_type</em>, <em class="sig-param">narrow_range</em>, <em class="sig-param">scaling_override</em>, <em class="sig-param">restrict_scaling_type</em>, <em class="sig-param">scaling_const</em>, <em class="sig-param">scaling_stats_op</em>, <em class="sig-param">scaling_impl_type</em>, <em class="sig-param">scaling_stats_reduce_dim</em>, <em class="sig-param">scaling_shape</em>, <em class="sig-param">scaling_min_val</em>, <em class="sig-param">bit_width_impl_type</em>, <em class="sig-param">restrict_bit_width_type</em>, <em class="sig-param">min_overall_bit_width</em>, <em class="sig-param">max_overall_bit_width</em>, <em class="sig-param">tracked_parameter_list_init</em>, <em class="sig-param">bit_width_impl_override</em>, <em class="sig-param">scaling_stats_input_view_shape_impl</em>, <em class="sig-param">scaling_stats_input_concat_dim</em>, <em class="sig-param">ternary_threshold</em>, <em class="sig-param">scaling_stats_sigma</em>, <em class="sig-param">override_pretrained_bit_width</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.parameter_quant.WeightQuantProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">brevitas.proxy.parameter_quant.ParameterQuantProxy</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>bit_width</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – The bit-width at which weights are quantized to. If <cite>bit_width_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">PARAMETER</span></code>, this value is
used for initialization. If <cite>quant_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">FP</span></code>, this value is ignored.</p></li>
<li><p><strong>quant_type</strong> (<a class="reference internal" href="brevitas.core.html#brevitas.core.quant.QuantType" title="brevitas.core.quant.QuantType"><code class="xref py py-class docutils literal notranslate"><span class="pre">QuantType</span></code></a>) – Type of quantization. If set to <code class="docutils literal notranslate"><span class="pre">FP</span></code>, no quantization is performed.</p></li>
<li><p><strong>narrow_range</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – Restrict range of quantized values to a symmetrical interval around 0. For example, given <cite>bit_width</cite> set to
8 and quant_type set to <code class="docutils literal notranslate"><span class="pre">INT</span></code>, if <cite>narrow_range</cite> is set to <code class="docutils literal notranslate"><span class="pre">True</span></code>, the range of quantized values is in
<code class="docutils literal notranslate"><span class="pre">[-127,</span> <span class="pre">127]</span></code>; If set to <code class="docutils literal notranslate"><span class="pre">False</span></code>, it’s in <code class="docutils literal notranslate"><span class="pre">[-128,127]</span></code>.</p></li>
<li><p><strong>restrict_scaling_type</strong> (<a class="reference internal" href="brevitas.core.html#brevitas.core.restrict_val.RestrictValueType" title="brevitas.core.restrict_val.RestrictValueType"><code class="xref py py-class docutils literal notranslate"><span class="pre">RestrictValueType</span></code></a>) – Type of restriction imposed on the values of the scaling factor of the quantized weights.</p></li>
<li><p><strong>scaling_const</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – If <cite>scaling_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">CONST</span></code>, this value is used as the scaling factor across all relevant
dimensions. Ignored otherwise.</p></li>
<li><p><strong>scaling_stats_op</strong> (<a class="reference internal" href="brevitas.core.html#brevitas.core.stats.StatsOp" title="brevitas.core.stats.StatsOp"><code class="xref py py-class docutils literal notranslate"><span class="pre">StatsOp</span></code></a>) – Type of statistical operation performed for scaling, if required. If <cite>scaling_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">STATS</span></code> or
<code class="docutils literal notranslate"><span class="pre">AFFINE_STATS</span></code>, the operation is part of the compute graph and back-propagated through. If <cite>scaling_impl_type</cite>
is set to <code class="docutils literal notranslate"><span class="pre">PARAMETER_FROM_STATS</span></code>, the operation is used only for computing the initialization of the
parameter, possibly across some dimensions. Ignored otherwise.</p></li>
<li><p><strong>scaling_impl_type</strong> (<a class="reference internal" href="brevitas.core.html#brevitas.core.scaling.ScalingImplType" title="brevitas.core.scaling.ScalingImplType"><code class="xref py py-class docutils literal notranslate"><span class="pre">ScalingImplType</span></code></a>) – Type of strategy adopted for scaling the quantized weights.</p></li>
<li><p><strong>scaling_stats_reduce_dim</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – Dimension within the shape determined by <cite>scaling_stats_input_view_shape_impl</cite> along which <cite>scaling_stats_op</cite> is
applied. If set to <code class="docutils literal notranslate"><span class="pre">None</span></code>, scaling is assumed to be over the whole tensor. Ignored whenever <cite>scaling_stats_op</cite>
is ignored.</p></li>
<li><p><strong>scaling_shape</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Tuple</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, …]) – Shape of the scaling factor tensor. This is required to be broadcastable w.r.t. the weight tensor to scale.</p></li>
<li><p><strong>scaling_min_val</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – Minimum value that the scaling factors can reach. This has precedence over anything else, including
<cite>scaling_const</cite> when <cite>scaling_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">CONST</span></code>. Useful in case of numerical instabilities.
If set to None, no minimum is imposed.</p></li>
<li><p><strong>bit_width_impl_type</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<a class="reference internal" href="brevitas.core.html#brevitas.core.bit_width.BitWidthImplType" title="brevitas.core.bit_width.BitWidthImplType"><code class="xref py py-class docutils literal notranslate"><span class="pre">BitWidthImplType</span></code></a>]) – Type of strategy adopted for precision at which the weights are quantized to when <cite>quant_type</cite> is set to
<code class="docutils literal notranslate"><span class="pre">INT</span></code>. Ignored otherwise.</p></li>
<li><p><strong>restrict_bit_width_type</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<a class="reference internal" href="brevitas.core.html#brevitas.core.restrict_val.RestrictValueType" title="brevitas.core.restrict_val.RestrictValueType"><code class="xref py py-class docutils literal notranslate"><span class="pre">RestrictValueType</span></code></a>]) – If <cite>bit_width_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">PARAMETER</span></code> and <cite>quant_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">INT</span></code>, this value constraints or
relax the bit-width value that can be learned. Ignored otherwise.</p></li>
<li><p><strong>min_overall_bit_width</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – If <cite>bit_width_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">PARAMETER</span></code> and <cite>quant_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">INT</span></code>, this value imposes a lower
bound on the learned value. Ignored otherwise.</p></li>
<li><p><strong>max_overall_bit_width</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – If <cite>bit_width_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">PARAMETER</span></code> and <cite>quant_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">INT</span></code>, this value imposes an upper
bound on the learned value. Ignored otherwise.</p></li>
<li><p><strong>tracked_parameter_list_init</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Parameter</span></code>) – Pytorch Parameter of which statistics are computed when <cite>scaling_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">STATS</span></code>,
<code class="docutils literal notranslate"><span class="pre">AFFINE_STATS</span></code> or <code class="docutils literal notranslate"><span class="pre">PARAMETER_FROM_STATS</span></code>. This value initializes the list of parameters that are
concatenated together when computing statistics.</p></li>
<li><p><strong>bit_width_impl_override</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<a class="reference internal" href="brevitas.core.html#brevitas.core.bit_width.BitWidthConst" title="brevitas.core.bit_width.BitWidthConst"><code class="xref py py-class docutils literal notranslate"><span class="pre">BitWidthConst</span></code></a>, <a class="reference internal" href="brevitas.core.html#brevitas.core.bit_width.BitWidthParameter" title="brevitas.core.bit_width.BitWidthParameter"><code class="xref py py-class docutils literal notranslate"><span class="pre">BitWidthParameter</span></code></a>, <code class="docutils literal notranslate"><span class="pre">None</span></code>]) – Override the bit-width implementation with an implementation defined elsewhere. Accepts BitWidthConst or
BitWidthParameter type of Modules. Useful for sharing the same learned bit-width between different layers.</p></li>
<li><p><strong>scaling_stats_input_view_shape_impl</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Module</span></code>) – When <cite>scaling_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">STATS</span></code>, <code class="docutils literal notranslate"><span class="pre">AFFINE_STATS</span></code> or <code class="docutils literal notranslate"><span class="pre">PARAMETER_FROM_STATS</span></code>,
this Module reshapes each tracked parameter before concatenating them together and computing their statistics.</p></li>
<li><p><strong>scaling_stats_input_concat_dim</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – When <cite>scaling_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">STATS</span></code>, <code class="docutils literal notranslate"><span class="pre">AFFINE_STATS</span></code> or <code class="docutils literal notranslate"><span class="pre">PARAMETER_FROM_STATS</span></code>,
this value defines the dimension along which the tracked parameters are concated after
<cite>scaling_stats_input_view_shape_impl</cite> is called, but before statistics are taken.</p></li>
<li><p><strong>ternary_threshold</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – Value to be used as a threshold when <cite>quant_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">TERNARY</span></code>. Ignored otherwise.</p></li>
<li><p><strong>scaling_stats_sigma</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>]) – Value to be used as sigma if <cite>scaling_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">STATS</span></code>, <code class="docutils literal notranslate"><span class="pre">AFFINE_STATS</span></code> or
<code class="docutils literal notranslate"><span class="pre">PARAMETER_FROM_STATS</span></code> and <cite>scaling_stats_op</cite> is set to <code class="docutils literal notranslate"><span class="pre">AVE_SIGMA_STD</span></code> or <code class="docutils literal notranslate"><span class="pre">AVE_LEARN_SIGMA_STD</span></code>.
Ignored otherwise. When <cite>scaling_impl_type</cite> is set to <code class="docutils literal notranslate"><span class="pre">STATS</span></code> or <code class="docutils literal notranslate"><span class="pre">AFFINE_STATS</span></code>, and
<cite>scaling_stats_op</cite> is set to <code class="docutils literal notranslate"><span class="pre">AVE_LEARN_SIGMA_STD</span></code>, the value is used for initialization.</p></li>
<li><p><strong>override_pretrained_bit_width</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – If set to <code class="docutils literal notranslate"><span class="pre">True</span></code>, when loading a pre-trained model that includes a learned bit-width, the pre-trained value
is ignored and replaced by the value specified by <code class="docutils literal notranslate"><span class="pre">bit-width</span></code>.</p></li>
</ul>
</dd>
</dl>
<dl class="method">
<dt id="brevitas.proxy.parameter_quant.WeightQuantProxy.add_tracked_parameter">
<code class="sig-name descname">add_tracked_parameter</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.parameter_quant.WeightQuantProxy.add_tracked_parameter" title="Permalink to this definition">¶</a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="brevitas.proxy.parameter_quant.WeightQuantProxy.forward">
<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.parameter_quant.WeightQuantProxy.forward" title="Permalink to this definition">¶</a></dt>
<dd><p>Defines the computation performed at every call.</p>
<p>Should be overridden by all subclasses.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Although the recipe for forward pass needs to be defined within
this function, one should call the <code class="xref py py-class docutils literal notranslate"><span class="pre">Module</span></code> instance afterwards
instead of this since the former takes care of running the
registered hooks while the latter silently ignores them.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Tuple</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">Tensor</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Tensor</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Tensor</span></code>]</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="brevitas.proxy.parameter_quant.WeightQuantProxy.int_weight">
<code class="sig-name descname">int_weight</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.parameter_quant.WeightQuantProxy.int_weight" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="brevitas.proxy.parameter_quant.WeightQuantProxy.re_init_tensor_quant">
<code class="sig-name descname">re_init_tensor_quant</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.parameter_quant.WeightQuantProxy.re_init_tensor_quant" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="brevitas.proxy.parameter_quant.BiasQuantProxy">
<em class="property">class </em><code class="sig-prename descclassname">brevitas.proxy.parameter_quant.</code><code class="sig-name descname">BiasQuantProxy</code><span class="sig-paren">(</span><em class="sig-param">quant_type</em>, <em class="sig-param">bit_width</em>, <em class="sig-param">narrow_range</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.parameter_quant.BiasQuantProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">brevitas.proxy.parameter_quant.ParameterQuantProxy</span></code></p>
<dl class="method">
<dt id="brevitas.proxy.parameter_quant.BiasQuantProxy.forward">
<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">input_scale</em>, <em class="sig-param">input_bit_width</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.parameter_quant.BiasQuantProxy.forward" title="Permalink to this definition">¶</a></dt>
<dd><p>Defines the computation performed at every call.</p>
<p>Should be overridden by all subclasses.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Although the recipe for forward pass needs to be defined within
this function, one should call the <code class="xref py py-class docutils literal notranslate"><span class="pre">Module</span></code> instance afterwards
instead of this since the former takes care of running the
registered hooks while the latter silently ignores them.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Tuple</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">Tensor</span></code>, <code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">Tensor</span></code>], <code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">Tensor</span></code>]]</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-brevitas.proxy.quant_proxy">
<span id="brevitas-proxy-quant-proxy-module"></span><h2>brevitas.proxy.quant_proxy module<a class="headerlink" href="#module-brevitas.proxy.quant_proxy" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="brevitas.proxy.quant_proxy.QuantProxy">
<em class="property">class </em><code class="sig-prename descclassname">brevitas.proxy.quant_proxy.</code><code class="sig-name descname">QuantProxy</code><a class="headerlink" href="#brevitas.proxy.quant_proxy.QuantProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.nn.modules.module.Module</span></code></p>
<dl class="method">
<dt id="brevitas.proxy.quant_proxy.QuantProxy.state_dict">
<code class="sig-name descname">state_dict</code><span class="sig-paren">(</span><em class="sig-param">destination=None</em>, <em class="sig-param">prefix=''</em>, <em class="sig-param">keep_vars=False</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.quant_proxy.QuantProxy.state_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a dictionary containing a whole state of the module.</p>
<p>Both parameters and persistent buffers (e.g. running averages) are
included. Keys are corresponding parameter and buffer names.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>a dictionary containing a whole state of the module</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>dict</p>
</dd>
</dl>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">module</span><span class="o">.</span><span class="n">state_dict</span><span class="p">()</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
<span class="go">[&#39;bias&#39;, &#39;weight&#39;]</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-brevitas.proxy.runtime_quant">
<span id="brevitas-proxy-runtime-quant-module"></span><h2>brevitas.proxy.runtime_quant module<a class="headerlink" href="#module-brevitas.proxy.runtime_quant" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="brevitas.proxy.runtime_quant.ActivationQuantProxy">
<em class="property">class </em><code class="sig-prename descclassname">brevitas.proxy.runtime_quant.</code><code class="sig-name descname">ActivationQuantProxy</code><span class="sig-paren">(</span><em class="sig-param">activation_impl</em>, <em class="sig-param">bit_width</em>, <em class="sig-param">signed</em>, <em class="sig-param">narrow_range</em>, <em class="sig-param">min_val</em>, <em class="sig-param">max_val</em>, <em class="sig-param">quant_type</em>, <em class="sig-param">float_to_int_impl_type</em>, <em class="sig-param">scaling_override</em>, <em class="sig-param">scaling_impl_type</em>, <em class="sig-param">scaling_per_channel</em>, <em class="sig-param">scaling_min_val</em>, <em class="sig-param">scaling_stats_sigma</em>, <em class="sig-param">scaling_stats_op</em>, <em class="sig-param">scaling_stats_buffer_momentum</em>, <em class="sig-param">scaling_stats_permute_dims</em>, <em class="sig-param">per_channel_broadcastable_shape</em>, <em class="sig-param">min_overall_bit_width</em>, <em class="sig-param">max_overall_bit_width</em>, <em class="sig-param">bit_width_impl_override</em>, <em class="sig-param">bit_width_impl_type</em>, <em class="sig-param">restrict_bit_width_type</em>, <em class="sig-param">restrict_scaling_type</em>, <em class="sig-param">override_pretrained_bit_width</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.runtime_quant.ActivationQuantProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#brevitas.proxy.quant_proxy.QuantProxy" title="brevitas.proxy.quant_proxy.QuantProxy"><code class="xref py py-class docutils literal notranslate"><span class="pre">brevitas.proxy.quant_proxy.QuantProxy</span></code></a></p>
<dl class="method">
<dt id="brevitas.proxy.runtime_quant.ActivationQuantProxy.forward">
<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.runtime_quant.ActivationQuantProxy.forward" title="Permalink to this definition">¶</a></dt>
<dd><p>Defines the computation performed at every call.</p>
<p>Should be overridden by all subclasses.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Although the recipe for forward pass needs to be defined within
this function, one should call the <code class="xref py py-class docutils literal notranslate"><span class="pre">Module</span></code> instance afterwards
instead of this since the former takes care of running the
registered hooks while the latter silently ignores them.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="brevitas.proxy.runtime_quant.ClampQuantProxy">
<em class="property">class </em><code class="sig-prename descclassname">brevitas.proxy.runtime_quant.</code><code class="sig-name descname">ClampQuantProxy</code><span class="sig-paren">(</span><em class="sig-param">signed</em>, <em class="sig-param">narrow_range</em>, <em class="sig-param">quant_type</em>, <em class="sig-param">ms_bit_width_to_clamp</em>, <em class="sig-param">clamp_at_least_init_val</em>, <em class="sig-param">min_overall_bit_width</em>, <em class="sig-param">max_overall_bit_width</em>, <em class="sig-param">msb_clamp_bit_width_impl_type</em>, <em class="sig-param">override_pretrained_bit_width</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.runtime_quant.ClampQuantProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#brevitas.proxy.quant_proxy.QuantProxy" title="brevitas.proxy.quant_proxy.QuantProxy"><code class="xref py py-class docutils literal notranslate"><span class="pre">brevitas.proxy.quant_proxy.QuantProxy</span></code></a></p>
<dl class="method">
<dt id="brevitas.proxy.runtime_quant.ClampQuantProxy.forward">
<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">input_scale</em>, <em class="sig-param">input_bit_width</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.runtime_quant.ClampQuantProxy.forward" title="Permalink to this definition">¶</a></dt>
<dd><p>Defines the computation performed at every call.</p>
<p>Should be overridden by all subclasses.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Although the recipe for forward pass needs to be defined within
this function, one should call the <code class="xref py py-class docutils literal notranslate"><span class="pre">Module</span></code> instance afterwards
instead of this since the former takes care of running the
registered hooks while the latter silently ignores them.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="brevitas.proxy.runtime_quant.FusedActivationQuantProxy">
<em class="property">class </em><code class="sig-prename descclassname">brevitas.proxy.runtime_quant.</code><code class="sig-name descname">FusedActivationQuantProxy</code><span class="sig-paren">(</span><em class="sig-param">activation_impl</em>, <em class="sig-param">tensor_quant</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.runtime_quant.FusedActivationQuantProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.jit.ScriptModule</span></code></p>
</dd></dl>

<dl class="class">
<dt id="brevitas.proxy.runtime_quant.TruncQuantProxy">
<em class="property">class </em><code class="sig-prename descclassname">brevitas.proxy.runtime_quant.</code><code class="sig-name descname">TruncQuantProxy</code><span class="sig-paren">(</span><em class="sig-param">signed</em>, <em class="sig-param">quant_type</em>, <em class="sig-param">ls_bit_width_to_trunc</em>, <em class="sig-param">trunc_at_least_init_val</em>, <em class="sig-param">min_overall_bit_width</em>, <em class="sig-param">max_overall_bit_width</em>, <em class="sig-param">lsb_trunc_bit_width_impl_type</em>, <em class="sig-param">explicit_rescaling</em>, <em class="sig-param">override_pretrained_bit_width</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.runtime_quant.TruncQuantProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#brevitas.proxy.quant_proxy.QuantProxy" title="brevitas.proxy.quant_proxy.QuantProxy"><code class="xref py py-class docutils literal notranslate"><span class="pre">brevitas.proxy.quant_proxy.QuantProxy</span></code></a></p>
<dl class="method">
<dt id="brevitas.proxy.runtime_quant.TruncQuantProxy.forward">
<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">input_scale</em>, <em class="sig-param">input_bit_width</em><span class="sig-paren">)</span><a class="headerlink" href="#brevitas.proxy.runtime_quant.TruncQuantProxy.forward" title="Permalink to this definition">¶</a></dt>
<dd><p>Defines the computation performed at every call.</p>
<p>Should be overridden by all subclasses.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Although the recipe for forward pass needs to be defined within
this function, one should call the <code class="xref py py-class docutils literal notranslate"><span class="pre">Module</span></code> instance afterwards
instead of this since the former takes care of running the
registered hooks while the latter silently ignores them.</p>
</div>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-brevitas.proxy">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-brevitas.proxy" title="Permalink to this headline">¶</a></h2>
</div>
</div>


           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, Alessandro Pappalardo

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>